#pragma once

#include <bst.h>

typedef struct avl_node avl_node_t;

struct avl_node {
	bst_node_t node;
	uword_s height;
};

static inline avl_node_t* avl_get_node_pn(bst_node_t* node_pn) {
	return (avl_node_t*)node_pn;
}

bbst_errno_s avl_add(bst_t* bst_p, const void* data_p);

static inline void avl_init(bst_t* bst_p, uword_s data_size, cmp_ft* cmp_f) {
	bst_p->root_pn = nullptr;
	bst_p->add_f = avl_add;
	bst_p->delete_f = nullptr;
	bst_p->data_offset = sizeof(avl_node_t);

	bst_p->data_size = (u32_s)data_size;
	bst_p->cmp_f = cmp_f;
}
